from flask_jwt_extended import JWTManager
from datetime import timedelta
import os

jwt = JWTManager()

def init_jwt(app):
    """初始化JWT配置"""
    # 从环境变量读取JWT密钥
    app.config['JWT_SECRET_KEY'] = os.getenv('JWT_SECRET_KEY')
    # 设置token有效期为30天
    app.config['JWT_ACCESS_TOKEN_EXPIRES'] = timedelta(days=30)
    jwt.init_app(app)